package com.express.ExpRefundRecord.dao;

import com.aqgj.util.BaseDaoImpl;
import com.express.ExpRefundRecord.bean.ExpRefundRecord;
import org.springframework.stereotype.Repository;
import java.util.List;


@Repository("ExpRefundRecordDao")
public class ExpRefundRecordDao extends BaseDaoImpl<ExpRefundRecord> {


    //获取退款记录表
    public List<Object[]> getRefundRecordList(Integer pageNo, Integer pageSize) {
        String sql = "SELECT r.id,r.fk_exp_order_id,r.`type`,r.order_money,r.refund_money,r.add_time, IFNULL(a.name,u.account) name " +
                "FROM exp_refund_record r " +
                "LEFT JOIN app_user a ON r.fk_manager_id=a.id " +
                "LEFT JOIN sys_user u ON r.fk_manager_id=u.id ORDER BY r.add_time DESC LIMIT ?,? ";
        return this.currentSession().createNativeQuery(sql).setParameter(1, (pageNo - 1) * pageSize).setParameter(2, pageSize).getResultList();
    }

    //获取退款记录条数
    public Integer getRefundRecordListCount() {
        String sql = "SELECT r.id,r.fk_exp_order_id,r.`type`,r.order_money,r.refund_money,r.add_time, IFNULL(a.name,u.account) name " +
                "FROM exp_refund_record r " +
                "LEFT JOIN app_user a ON r.fk_manager_id=a.id " +
                "LEFT JOIN sys_user u ON r.fk_manager_id=u.id  ";
        return this.currentSession().createNativeQuery(sql).getResultList().size();
    }
}